<template>
  <a-result status="success" title="您的考试已经结束" sub-title="现在你可以关闭该页面了">
    <template #extra>
      <a-button key="console" @click="getScore" type="primary">获取分数</a-button>
      <a-button key="view" @click="getResult">查看解析</a-button>
    </template>
  </a-result>
</template>

<script>
import { message } from "ant-design-vue";
import { defineComponent } from "vue";
import { useRoute, useRouter } from "vue-router";
import { getExamScore } from "../../utils/api";
export default defineComponent({
  setup() {
    const route = useRoute();
    const router = useRouter();
    const examId = route.params["examId"];
    const getScore = () => {
      getExamScore(examId).then((res) => {
        message.success(`你的成绩为: ${res.data.data} 分`);
      });
    };
    const getResult = () => {
      router.push({ name: "ViewResult", params: { examId } });
    };

    return {
      getScore,
      getResult,
    };
  },
});
</script>
